﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Threading;

namespace de.codingfreaks.libs.cfThreadingTools.Extensions
{
    /// <summary>
    /// Provides extensions for <c>System.Windows.Threading.DispatcherObject and subsequent objects.</c>
    /// </summary>
    public static class DispatcherExtensions
    {

        /// <summary>
        /// Sets the IsEnabled-property of a WPF control to true.
        /// </summary>
        /// <param name="dobjTarget">The WPF control for extensions-purposes.</param>
        public static void EnableThreadSafe(this DispatcherObject dobjTarget)
        {
            BaseTools.SetWpfPropertyValue(dobjTarget, "IsEnabled", true);
        }

        /// <summary>
        /// Sets the IsEnabled-property of a WPF control to false.
        /// </summary>
        /// <param name="dobjTarget">The WPF control for extensions-purposes.</param>
        public static void DisableThreadSafe(this DispatcherObject dobjTarget)
        {
            BaseTools.SetWpfPropertyValue(dobjTarget, "IsEnabled", false);
        }

        /// <summary>
        /// Sets the Visibility-property of a WPF control to Hidden.
        /// </summary>
        /// <param name="dobjTarget">The WPF control for extensions-purposes.</param>
        public static void HideThreadSafe(this DispatcherObject dobjTarget)
        {
            BaseTools.SetWpfPropertyValue(dobjTarget, "Visibility", Visibility.Hidden);
        }

        /// <summary>
        /// Sets the Visibility-property of a WPF control to Visible.
        /// </summary>
        /// <param name="dobjTarget">The WPF control for extensions-purposes.</param>
        public static void UnhideThreadSafe(this DispatcherObject dobjTarget)
        {
            BaseTools.SetWpfPropertyValue(dobjTarget, "Visibility", Visibility.Visible);
        }

    }
}
